package com.xcity.game.land;

import java.util.List;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Binding;
import naga.x.game.template.annotation.Excel;

/**
 * 地标列表
 * @author yang.li
 *
 */
@Excel(value = "land.xlsx", sheet = 0)
public class LandTemplate extends Template {

	/** 地标名称 */
	protected String name;

	/** 描述 */
	protected String desc;

	/** 图片 */
	protected String image;

	/** 收购所消耗的货币类型(1:现金;2:钻石) */
	protected byte costType;
	
	protected List<LandBuyTemplate> buyTemplates;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public byte getCostType() {
		return costType;
	}

	public void setCostType(byte costType) {
		this.costType = costType;
	}
	
	public List<LandBuyTemplate> getBuyTemplates() {
		return buyTemplates;
	}

	@Binding(type = LandBuyTemplate.class, field = "id", ref = "landId")
	public void setBuyTemplates(List<LandBuyTemplate> buyTemplates) {
		this.buyTemplates = buyTemplates;
	}
	
	public LandBuyTemplate getBuyTemplate(int level) {
		List<LandBuyTemplate> temps = buyTemplates;
		if (temps == null || temps.isEmpty()) {
			return null;
		}
		if (level < 1 || level > temps.size()) {
			level = 1;
		}
		return temps.get(level - 1);
	}

	@Override
	public void validate() throws TemplateException {}
}
